import requests
from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import HttpResponse, redirect


# 目前不需要用到中间件，请保留
class AuthMiddleware(MiddlewareMixin):
    """用户登录中间件"""
    def process_request(self, request):
        """如果方法中没有返回值(None)，则中间件允许用户向后走"""
        if request.path_info == '/login/':
            return

        info_dict = request.session.get('info')
        if info_dict:
            return

        return redirect('/login/')
